package com.yy.job.service;

import com.yy.job.core.domain.JobDomain;
import com.yy.job.core.domain.JobStepDomain;
import com.yy.job.core.domain.JobStepExecLogDomain;
import com.yy.job.core.domain.context.JobContext;
import com.yy.job.core.domain.context.JobStepContext;

public interface IJobManager {
	
	/**
	 * 开始执行job
	 * 
	 * @param jobContext
	 */
	void startJobExecute(JobContext jobContext);
	
	/**
	 * 结束执行job
	 * 
	 * @param jobContext
	 */
	void endJobExecute(JobContext jobContext);
	
	/**
	 * 开始执行jobStep
	 * 
	 * @param jobContext
	 */
	void startJobStepExecute(JobStepContext jobStepContext);
	
	/**
	 * 结束执行jobStep
	 * 
	 * @param jobContext
	 */
	void endJobStepExecute(JobStepContext jobStepContext);
	
	/**
	 * 保存日志并更新执行次数
	 * 
	 * @param jobStepDomain
	 * @param jobTaskLog
	 * @return
	 */
	Long saveJobStepExecResult(JobStepDomain jobStepDomain, JobStepExecLogDomain jobTaskLog);
	
	/**
	 * 根据project + moduleCode + jobCode + businessNo查询，获取级联数据
	 * 
	 * @param moduleCode
	 * @param jobCode
	 * @param businessNo
	 * @return
	 */
	JobDomain queryJobByBusinessNo(String projectCode, String moduleCode, String jobCode, String businessNo);
	
	/**
	 * 根据版本号加锁
	 * 
	 * @param jobDomain
	 * @param modifier
	 * @return
	 */
	int lockJobByVersion(JobDomain jobDomain, String modifier);
	
	/**
	 * 提交job
	 * 
	 * @param paramJob
	 * @return
	 * @throws Exception
	 */
	Long submit(JobDomain job);
}
